<template>
<div>
    <button @click="showPDFImg">展示PDF-img</button>
    <button @click="showPDFText">展示PDF-text</button>
</div>
</template>

<script>
// import pdfUrl from "@/assets/pdf/test.pdf";
import {pdfWatermarking,printPdfDocument} from "@/utils/pdfWatermarking";
export default {
    name: "PDFWatermarking",
    data(){
        return {
            pdfUrl : "https://ziliao.xisaiwang.cn/attach/attach/2024-5/366/d415e9f6-0ab6-41a5-b37b-a7514fc5f7d4.pdf",
            imgUrl:'https://lstatic.xisaiwang.com/educity/pc/cmsng/img/index/img_logo.png',
            pdfData:undefined,
        }
    },
    methods: {
        async showPDFImg() {
            try {
                // const pdfUrl = '/assets/pdf/test.pdf';
                // const imgUrl = '@/assets/pdf/test.jpg';
                console.log(this.pdfUrl)
                // 导入的pdf文件路径
                const res = await pdfWatermarking(this.pdfUrl,this.imgUrl,2);
                console.log(res)
                await printPdfDocument(res);
            } catch (error) {
                console.error(`发生错误: ${error.message}`);
            }

        },
        async showPDFText() {
            try {
                // const pdfUrl = '/assets/pdf/test.pdf';
                // const imgUrl = '@/assets/pdf/test.jpg';
                console.log(this.pdfUrl)
                // 导入的pdf文件路径
                const res = await pdfWatermarking(this.pdfUrl,'test',1,0.5);
                console.log(res)
                await printPdfDocument(res);
            } catch (error) {
                console.error(`发生错误: ${error.message}`);
            }

        }
    }
}
</script>

<style scoped>

</style>
